<template>
	<view>
		<view class="cu-bar search bg-white b-radius">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input :adjust-position="false"  type="text" placeholder="请输入商品名"  @tap="toSearch()"
					disabled="true"></input>
			</view>
			<view class="text-green" @tap="toSelectArea()">
				{{selectCommunityName}}<text class="cuIcon-refresharrow"></text></view>
		</view>
		<view class="padding-lr-sm">
			<vc-category :category-list="categoryList"></vc-category>
			<vc-ads></vc-ads>
		</view>

		<vc-bottom-black></vc-bottom-black>

	</view>
</template>

<script>
	import fixedSearch from '../../components/fixed-search/fixed-search.vue'; 
	
	import vcCategory from '@/components/vc-category/vc-category.vue'

	import vcAds from '@/components/vc-ads/vc-ads.vue'

	import vcBottomBlack from '@/components/vc-bottom-black/vc-bottom-black.vue';
	
	import param from '../../constant/param.js'
	

	import {
		getIndexCategoryList
	} from '../../api/index/indexApi.js'
	import {
		sliceArray
	} from '../../lib/java110/utils/ArrayUtil.js'
	export default {
		data() {
			return {
				selectCommunityName:"",
				categoryList: [],
				addlistdata:[
					{
						title:"我的发布",
						src:"/static/images/market_my.png"
					}
				]
			}
		},
		components: {
			vcCategory,
			vcAds,
			vcBottomBlack
		},
		onLoad(options) {
			this.vc.onLoad(options);
			this.vc.setStorageSync('mallIndexRefresh','1');
		},
		onShow: function(options) {
			let _mallIndexRefresh = this.vc.getStorageSync('mallIndexRefresh');
			if(_mallIndexRefresh != '1'){
				return;
			}
			this.categoryList = this._getCategoryList();
			let community = uni.getStorageSync("_selectCommunity");
			if(community){
				this.selectCommunityName = community.name;
			}else{
				
			}
			this.vc.setStorageSync('mallIndexRefresh','0');
		},
		methods: {
			
			_getCategoryList() {
				let _that = this
				getIndexCategoryList()
					.then(function(result) {
						let categoryData = result
						_that.categoryList = sliceArray(categoryData, 8)
					})
			},
			addlisttap:function(index){/*第一个序列为0,第二个为1,以此类推;当值为-1代表点击的是遮慕层*/
				this.vc.loginAuth();
				let _that = this;
				if(index == 0){
					this.vc.navigateTo({
						url:'/pages/myOrder/myOrder'
					},true);
					return ;
				}
			},
			//搜索跳转
			toSearch(e){
				this.vc.navigateTo({
					url: `/pages/goods/HM-search?searchType=3`
				},true)
			},
			//切换小区
			toSelectArea(e){
				this.vc.navigateTo({
					url: `/pages/selectcommunity/selectcommunity`
				},true)
			}
		}
	}
</script>

<style>

</style>
